#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>


struct Point {
    int x;
    int y;
};

/**
 * 时间复杂度：O(n*m)
 * 空间复杂度：O(n+m)
 * 
 * 开锁
 * @return
 */
int main() {
    Point keys[110]{};
    Point locks[110]{};

    int n, m;
    scanf("%d %d", &n, &m);

    for (int i = 0; i < n; i++) {
        scanf("%d %d", &keys[i].x, &keys[i].y);
    }

    for (int i = 0; i < m; i++) {
        scanf("%d %d", &locks[i].x, &locks[i].y);
    }

    for (int i=0; i < n;i++) {
        int cnt = 0;
        for (int j=0; j < m; j++) {
            if (keys[i].x * locks[j].y == keys[i].y * locks[j].x) {
                cnt++;
            }
        }
        printf("%d\n", cnt);
    }

    return 0;
}



